﻿using UnityEngine;
using System.Collections;

public class LastStageClearScreen : MonoBehaviour
{
	// Constants
	
	const float			c_epligueJumpDelay	= 3f;
	const float			c_blinkInterval		= 0.3f;


	// Properties

	[SerializeField]
	TextMesh			m_text;


	
	void OnEnable()
	{
		StartCoroutine(DelayAndJump());			// 활성화되었을 시 점프 루틴 가동
		StartCoroutine(TextBlink());			// 텍스트 깜빡임
	}

	IEnumerator DelayAndJump()
	{
		yield return new WaitForSeconds(c_epligueJumpDelay);

		GameScene.stageDataToLoad	= StageInfos.epilogue;	// 에필로그로 점프
		Application.LoadLevel("GameScene");
	}

	IEnumerator TextBlink()
	{
		while(true)
		{
			yield return new WaitForSeconds(c_blinkInterval);
			m_text.renderer.enabled	= !m_text.renderer.enabled;
		}
	}
}
